import { RechargeActiveItem } from "../loginNotice/OpenRecharge/RechargeActiveItem";
import { SDayRechargeRewardItem } from "../../../../Message/Public/SDayRechargeRewardItem";
import { ItemData } from "../../resource/info/ItemData";
import { Language } from "../../../../extend/language/Language";
import { EffectManager } from "../../manager/EffectManager";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
//class TimeLimitsGiftItem
    
    export  class TimeLimitsGiftItem extends RechargeActiveItem
    {
        constructor()
        {
            super();
            addEventListener(flash.events.MouseEvent.CLICK, this.onMouseClickHandler);
            return;
        }

        protected onMouseClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            return;
        }

        public updateRewardInfo(arg1: SDayRechargeRewardItem): void
        {
            var loc1=null;
            if (arg1) 
            {
                this._rewardInfo = arg1;
                loc1 = new ItemData(arg1.itemCode);
                _baseItem.itemData = loc1;
                _nameTxt.text = loc1.itemInfo.item.name;
                if (arg1.state != 0) 
                {
                    if (arg1.state != 1) 
                    {
                        _getBtn.enabled = false;
                        _getBtn.label = Language.getString(20152);
                        EffectManager.glowFilterUnReg(_getBtn);
                    }
                    else 
                    {
                        _getBtn.enabled = true;
                        EffectManager.glowFilterReg(_getBtn, [_glowYellow], 0.5, 6, 3, 20);
                    }
                }
                else 
                {
                    _getBtn.enabled = false;
                    _getBtn.label = Language.getString(20146);
                    EffectManager.glowFilterUnReg(_getBtn);
                }
            }
            return;
        }

        protected /* override */ onGetBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._rewardInfo) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.GetTimeLimtsGifts, this._rewardInfo.itemCode));
            }
            return;
        }

        /* internal */ /* var */_rewardInfo: SDayRechargeRewardItem;
    }
